package com.lsh.controller;

import com.lsh.entity.Result;
import com.lsh.pojo.Setmeal;
import com.lsh.service.SetmealService;
import com.lsh.utils.QiNiuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    /**
     * 查询所有套餐
     * @return
     */
    @GetMapping("/getSetmeal")
    public Result getSetmeal(){
        List<Setmeal> setmealList = setmealService.getSetmeal();
        for (Setmeal setmeal : setmealList) {
            setmeal.setImg(QiNiuUtils.DOMAIN + setmeal.getImg());
        }
        return new Result(true,"体检套餐查询成功",setmealList);
    }

    @GetMapping("/findSetmealDetailById")
    public Result findSetmealDetailById(@RequestParam("id") Integer id) {
        Setmeal setmeal = setmealService.findSetmealDetailById(id);
        setmeal.setImg(QiNiuUtils.DOMAIN + setmeal.getImg());
        return new Result(true, "查询成功", setmeal);
    }
    @GetMapping("/findById")
    public Result findById(@RequestParam("id") Integer id){
        Setmeal setmeal = setmealService.findById(id);
        setmeal.setImg(QiNiuUtils.DOMAIN+setmeal.getImg());
        return new Result(true,"体检套餐查询成功",setmeal);
    }
}
